package com.ytzl.common;

/**
 * @Author: ThinkPad
 * @Creation: 2021/9/15 13:42
 * @Desc: 统一返回的实体类型
 */
public class ResponseDataUtils {
    public static <T> ResponseData buildSuccess(T data) {
        return new ResponseData<T>(CodeResultEnums.SUCCESS, data);
    }

    public static ResponseData buildSuccess() {
        return new ResponseData(CodeResultEnums.SUCCESS);
    }

    public static ResponseData buildSuccess(String msg) {
        return new ResponseData(CodeResultEnums.SUCCESS.getCode(), msg);
    }

    public static ResponseData buildSuccess(Integer code, String msg) {
        return new ResponseData(code, msg);
    }

    public static <T> ResponseData buildSuccess(Integer code, String msg, T data) {
        return new ResponseData<T>(code, msg, data);
    }

    public static ResponseData buildSuccess(CodeResultEnums CodeResultEnums) {
        return new ResponseData(CodeResultEnums);
    }

    public static <T> ResponseData buildError(T data) {
        return new ResponseData<T>(CodeResultEnums.ERROR, data);
    }

    public static ResponseData buildError() {
        return new ResponseData(CodeResultEnums.ERROR);
    }

    public static ResponseData buildError(String msg) {
        return new ResponseData(CodeResultEnums.ERROR.getCode(), msg);
    }

    public static ResponseData buildError(Integer code, String msg) {
        return new ResponseData(code, msg);
    }

    public static <T> ResponseData buildError(Integer code, String msg, T data) {
        return new ResponseData<T>(code, msg, data);
    }

    public static ResponseData buildError(CodeResultEnums CodeResultEnums) {
        return new ResponseData(CodeResultEnums);

    }
}
